package com.learn.boot.filter;


import jakarta.servlet.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.io.IOException;
/**
 * 过滤器
 * @author:         MI
 * @email:          448341911@qq.com
 * @createDate:     2023/11/11 22:35
 * @updateUser:     MI
 * @updateDate:     2023/11/11 22:35
 * @updateRemark:   修改内容
 * @version:        v1.0
 */
@Slf4j
@Component
public class LoginFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        log.info(">>>>>>>>>>>>SampleFilter#init初始化操作");
    }

    @Override
    public void destroy() {
        log.info(">>>>>>>>>>>>SampleFilter#destroy销毁操作");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        // 这里可以执行预处理操作
        chain.doFilter(request, response); // 调用下一个过滤器或目标资源
        // 这里可以执行后处理操作
    }
}
